<?php
/**
 * Created by PhpStorm.
 * User: zhaobl
 * Date: 2017\11\9 0009
 * Time: 14:56
 */

namespace System;

class Router
{
    public $class = 'Index';
    public $action = 'index';
    public $param = '';

    public function __construct()
    {
        $this->parseUrl();
        Loader::load_class(__CLASS__,$this);
    }

    //解析Url
    private function parseUrl()
    {
        //p($_SERVER);
        //exit;
        if(isset($_SERVER['PATH_INFO']) && $_SERVER['REQUEST_URI'] != '/'){
            $arr = explode('/',$_SERVER['PATH_INFO']);
            if(isset($arr[1]) && !empty($arr[1])){
                $this->class = ucwords(strtolower($arr[1]));
            }
            if(isset($arr[2]) && !empty($arr[2])){
                $this->action = strtolower($arr[2]);
            }
        }
    }
}